home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3994 < prev    next >
Encoding:
Text File  |  1996-08-05  |  3.6 KB  |  135 lines

  1. Path: reno.WPI.EDU!vittohue
  2. From: Jose Andres Giraldez <vittohue@wpi.edu>
  3. Newsgroups: comp.lang.c
  4. Subject: HELP..Need to find why atan2 gives..
  5. Date: Thu, 1 Feb 1996 01:30:03 -0500
  6. Organization: Worcester Polytechnic Institute
  7. Message-ID: <Pine.OSF.3.91.960201012731.27628B-100000@reno.WPI.EDU>
  8. NNTP-Posting-Host: reno.wpi.edu
  9. Mime-Version: 1.0
  10. Content-Type: TEXT/PLAIN; charset=US-ASCII
  11.  
  12. I need to find why atan2 gives a number smaller than -180 and greater 
  13. than 180.
  14. ??????????
  15.  
  16. /*It works on BIGWPI.wpi.edu*/
  17. #include <stdio.h>
  18. #include <float.h>
  19. #include <math.h>
  20. #include "/cs/cs1005/problems/problem2/problem2.h"
  21. int main ()
  22. {
  23.   int Pi=3.14159, count, n_rows, n_columns;
  24.  
  25.   float limit;
  26.   float temporary;
  27.  
  28.   double degrees[N_MEAS];
  29.   double min_rad_deri;
  30.   double max_rad_deri;
  31.   double derivation[N_MEAS];
  32.   double theta[N_MEAS];
  33.   double radius[N_MEAS];
  34.   double AvgRadius;
  35.   double radius_sum;     /* This will find the sum of ALL the radius */
  36.  
  37.  
  38.   /*Set loop for all N_MEAS*/
  39.   for (count = 0; count < N_MEAS; count++)
  40.     {
  41.  
  42.       /*Find all values for theta*/
  43.       radius[count] = sqrt((x[count] * x[count]) + (y[count] * y[count]));
  44.  
  45.       /*Find all values fors radius*/
  46.       theta[count] = atan2(y[count], x[count]);
  47.  
  48.       printf("Here is r: %f and theta: %f\n",  radius[count],  theta[count]);
  49.  
  50.       /*Find the Sum of all the Radi*/
  51.       radius_sum = radius_sum + radius[count];
  52.  
  53.       /*Use the float.h to see if the radius growing is a problem*/
  54.       /*printf("DEBUG: %f\n", DBL_MAX - radius_sum);*/
  55.       /*THe radius_sum is fine*/
  56.     }
  57.   /*Find the AVG Radius*/
  58.  
  59.   if (radius_sum <0)
  60.     {
  61.       radius_sum = radius_sum * -1;
  62.     }
  63.   else
  64.     {
  65.       AvgRadius = (float) radius_sum / N_MEAS;
  66.       printf("This is the AVG Radius: %f\n",AvgRadius);
  67.     }
  68.  
  69.   /*Find the deviations from the avg radius*/
  70.   for (count=0; count < N_MEAS; count++)
  71.      { 
  72.       derivation[count] = (float) AvgRadius - radius[count];
  73.       /*printf("THese are the derivations: %f\n",derivation[count]);*/
  74.     }
  75.   /*Convert theta from radians to degrees*/
  76.   {
  77.     for (count = 0; count<N_MEAS; count++)
  78.       {
  79.         degrees[count] =  (double) ((theta[count] * 180)/Pi)+Pi;
  80.         printf("THese are the degrees: %f\n",degrees[count]);
  81.       }
  82.   }
  83.   /*Find the maximum and minimum for the y-axis*/
  84.   {  
  85.     float min_rad_deri = 80.0;
  86.     float max_rad_deri = 0.0;
  87.     float temporary;
  88.     for(count= 0; count<N_MEAS; count++)
  89.       {
  90.         temporary=derivation[count];
  91.         if (min_rad_deri > temporary)
  92.           { 
  93.             min_rad_deri = temporary;
  94.           }
  95.         temporary=derivation[count];
  96.         if (max_rad_deri < temporary)
  97.           { 
  98.             max_rad_deri = temporary;
  99.           }
  100.       }
  101.     printf("The minimum derivation from avg radius: %f\n",min_rad_deri);
  102.     printf("The maximum derivation from avg radius: %f\n",max_rad_deri);
  103.   }
  104.       
  105.   /*Compare the min and max to obtain the limits for the graph*/
  106.   {  
  107.     if ((min_rad_deri * -1) > max_rad_deri)
  108.       {
  109.         limit = min_rad_deri;
  110.       }
  111.     if ((min_rad_deri * -1) < max_rad_deri)
  112.       {
  113.         limit = max_rad_deri;
  114.       }
  115.  
  116.     /*Design the graph*/
  117.     {
  118.  
  119.     }
  120.   }
  121.   double degrees =0;
  122.   double radius=0;
  123.   double theta=0;
  124.   Pi=3.14159;
  125.             
  126. }
  127.  
  128.  
  129. /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  130. --- Jose A. Giraldez "vittohueQwpi.edu"  Worcester Polytechnic Institute ---
  131. --- "I want to die quietly like my   |            EMSEP CLASS '99        ---
  132. --- Grandfather, not screaming like  |        Visual WEB. Programming    ---
  133. --- the people in his car."          |                SHPE & HSA            ---
  134. \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  135.